package org.blackcat.common;

import java.net.URLDecoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * String工具包
 * 
 * @author Duo Duo
 *
 */
public final class StringUtils {

	/**
	 * 正则贩毒案
	 * @param content
	 * @param regix
     * @return 匹配返回true,否则返回false
     */
	public static final boolean regularMatch(String content,String regix){
		Pattern pattern = Pattern.compile(regix);
		Matcher matcher = pattern.matcher(content);
		return matcher.matches();
	}

	/**
	 * 字符串非空判断
	 * 
	 * @param str
	 * @return
	 */
	public static final boolean isNullOrEmpty(String str) {
		if (str == null || str.isEmpty()) {
			return true;
		}
		return false;
	}

	/**
	 * 是否是邮箱判断
	 * 
	 * @param str
	 * @return
	 */
	public static final boolean isEmail(String str) {
		String regex = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(str);
		return matcher.matches();
	}
}
